@echo off
setlocal

:: 设置颜色输出
set RED=[91m
set GREEN=[92m
set YELLOW=[93m
set NC=[0m

echo %GREEN%Installing dependencies for CTPQuoteEngine...%NC%

:: 检查是否以管理员权限运行
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo %YELLOW%Please run as Administrator%NC%
    exit /b 1
)

:: 检查是否安装了Chocolatey
where choco >nul 2>&1
if %errorLevel% neq 0 (
    echo %YELLOW%Installing Chocolatey...%NC%
    @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
    if %errorLevel% neq 0 (
        echo %RED%Failed to install Chocolatey%NC%
        exit /b 1
    )
)

:: 安装依赖
echo %GREEN%Installing dependencies...%NC%

:: 安装Visual Studio Build Tools
echo %GREEN%Installing Visual Studio Build Tools...%NC%
choco install visualstudio2019buildtools -y
choco install visualstudio2019-workload-vctools -y

:: 安装CMake
echo %GREEN%Installing CMake...%NC%
choco install cmake -y

:: 安装Qt
echo %GREEN%Installing Qt...%NC%
choco install qt5-sdk -y

:: 安装vcpkg (用于安装spdlog)
echo %GREEN%Installing vcpkg and spdlog...%NC%
if not exist "C:\vcpkg" (
    git clone https://github.com/Microsoft/vcpkg.git "C:\vcpkg"
    call C:\vcpkg\bootstrap-vcpkg.bat
    C:\vcpkg\vcpkg integrate install
)
C:\vcpkg\vcpkg install spdlog:x64-windows

:: 创建必要的目录
echo %GREEN%Creating necessary directories...%NC%
if not exist "C:\leexMarketLib\flow" mkdir "C:\leexMarketLib\flow"
if not exist "C:\leexMarketLib\logs" mkdir "C:\leexMarketLib\logs"

echo %GREEN%Dependencies installation completed!%NC%
echo %YELLOW%Note: Make sure CTP API libraries are properly installed in include/CTP directory%NC%

endlocal 